package io.renren.modules.bmx.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.bmx.entity.ErrorEntity;
import io.renren.modules.bmx.service.ErrorService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 错题
 *
 * @author HuangKexiang
 * @email yesjava@126.com
 * @date 2021-03-01 04:10:13
 */
@RestController
@RequestMapping("bmx/error")
public class ErrorController {
    @Autowired(required = false)
    private ErrorService errorService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = errorService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		ErrorEntity error = errorService.getById(id);

        return R.ok().put("error", error);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ErrorEntity error){
		errorService.save(error);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ErrorEntity error){
		errorService.updateById(error);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		errorService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
